﻿<table class="unit-table forum">
    <thead>
        <tr>
            <th>@T(Res.Name("Forum"))</th>
            <th>@T(Res.Name("TopicCount"))</th>
            <th>@T(Res.Name("PostCount"))</th>
            <th>@T(Res.Name("LastTopic"))</th>
        </tr>
    </thead>
    <tbody>
    @if((Model.Items as IEnumerable<dynamic>).Any())
    {
        foreach(var i in Model.Items)
        {
            var t_forum = (i.Translations as IEnumerable<dynamic>)
                .SingleOrDefault(x => JDM.Int32(x.Language.EntityID) ==
                    JDM.Int32(Svc.Localization.Language.EntityID));
            <tr class="unit forum">
                <td>
                    <h5><a href="@Url.Action(Loc.Act("Show").Set(new
                    {
                        id = JDM.Int32(i.EntityID)
                    }).Localized())" title="@(t_forum != null ? JDM.String(t_forum.Name) : JDM.String(i.EntityID))">@(t_forum != null ? JDM.String(t_forum.Name) : JDM.String(i.EntityID))</a></h5>
                    @{
                        Html.RenderPartial("_Description", (object)i);
                    }
                </td>
                <td>@JDM.Int32(i.TopicCount)</td>
                <td>@JDM.Int32(i.PostCount)</td>
                <td>
                @if(i.LastTopic != null)
                {
                    <a href="@Url.Action(Loc.Act("Show").Ctrl("Topic").Set(new
                    {
                        id = JDM.Int32(i.LastTopic.EntityID)
                    }).Localized())">@JDM.String(i.LastTopic.Title)</a><br/>
                    <a href="@Url.Action(Loc.Act("Show").Ctrl("Account").NoArea().Set(new
                    {
                        id = JDM.Int32(i.LastTopic.Member.Account.EntityID)
                    }).Localized())">@T(Res.In("Common").Of("Expr").Name("By"), JDM.String(i.LastTopic.Member.Account.Username))</a><br/>
                    @Svc.DateTimeRel((DateTime)JDM.DateTime(i.LastTopic.CreatedOn))
                }
                </td>
            </tr>
        }
    }
    else
    {
        <tr>
            <td class="empty" colspan="4"><span>@T(Res.In("Common").Of("Expr").Name("NoData"))</span></td>
        </tr>
    }
    </tbody>
</table>